<%@ page contentType="application/json; charset=UTF-8" pageEncoding="UTF-8" errorPage="/error.jsp"%>
<%@page import="dbexp.model.User"%>
<%@page import="dbexp.model.DbObject"%>
<%@page import="dbexp.model.db.DbUser"%>
<%@page import="dbexp.connection.DbMetaData"%>
<%@page import="dbexp.connection.DbConnection"%>
<%@page import="org.json.JSONObject"%>
<%@page import="org.json.JSONArray"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%
DbUser u = (DbUser)session.getAttribute("USER");
List<DbObject> allObs =  new ArrayList<DbObject>();
	allObs = DbMetaData.getSystemPrivs(u);
	String user = request.getParameter("user");
	if(user!=null){
		User wu = DbMetaData.getUser(u,user);
		for(int i=0;i<wu.getSystemPrivs().size();i++){
			allObs.remove(new DbObject(wu.getSystemPrivs().get(i)));
		}
	}
	JSONArray data = new JSONArray();
	for (int i = 0; i < allObs.size(); i++) {
		DbObject o = allObs.get(i);
		JSONObject json = new JSONObject();
		json.put("name", o.getName());
		data.put(json);
	}
out.clearBuffer();%><%=new JSONObject().
																			put("success", true).
																			put("data",data)%>
